//管理设备数据相关
import {defineStore} from "pinia";
import {ref} from "vue";
import {useUserPermissionAPI} from '@/apis/userPermission.ts';


export const userPermissionStore=defineStore('userPermission',()=>{

        //1.定义菜单的数据的state
        const usePermissionList=ref([]);
        const flag=ref(false);

        //获取当前登录用户的权限
        const getUserPermissionList=async ()=>{
            const res=await useUserPermissionAPI();
            usePermissionList.value=res.data;
            let flagDelete =usePermissionList.value.includes('sys:delete');
            let flagModify =usePermissionList.value.includes('sys:modify');
            if (flagDelete && flagModify){
                flag.value=true;
            }
        }


        //3.以对象的格式把state和action return
        return {
            usePermissionList,getUserPermissionList,flag
        }
    }

)